<template>
  <div class="contentBox" @click="$router.push('post/detail?id='+textData.id)">
    <!-- 或没图片单图片 -->
    <el-row type="flex" :gutter="10" v-if="textData.images.length < 3" class="dangtu">
      <!-- 图片 -->
      <el-col :span="8" class="imgBox" v-if="textData.images.length">
        <img :src="textData.images[0]" alt />
      </el-col>
      <!-- 文本 -->
      <el-col :span="textData.images.length?16:24" class="wenbenBox">
        <h5>{{textData.title}}</h5>
        <div v-html="textData.summary " class="content"></div>
        <div class="ftbox">
          <div class="ft-fl">
            <i class="el-icon-location-outline"></i>
            <span>{{textData.cityName}} by</span>
            <a href="#">
              <img :src="$axios.defaults.baseURL+textData.account.defaultAvatar" alt />
              <span>{{textData.account.nickname}}</span>
            </a>
            <i class="el-icon-view"></i>
            <span>{{textData.watch!=null?textData.watch:0}}</span>
          </div>
          <div class="ft-rg">{{textData.like==null?0:textData.like}}赞</div>
        </div>
      </el-col>
    </el-row>

    <!-- 多图 -->
    <div v-if="textData.images.length >= 3" class="duotu">
      <h5>{{textData.title}}</h5>
      <div v-html="textData.summary" class="content"></div>
      <el-row class="duotuimg" type="flex" :gutter="15">
        <el-col :span="8">
          <img :src="textData.images[0]" alt />
        </el-col>
        <el-col :span="8">
          <img :src="textData.images[1]" alt />
        </el-col>
        <el-col :span="8">
          <img :src="textData.images[2]" alt />
        </el-col>
      </el-row>
      <div class="ftbox">
        <div class="ft-fl">
          <i class="el-icon-location-outline"></i>
          <span>{{textData.cityName}} by</span>
          <a href="#">
            <img :src="$axios.defaults.baseURL+textData.account.defaultAvatar" alt />
            <span>{{textData.account.nickname}}</span>
          </a>
          <i class="el-icon-view"></i>
          <span>{{textData.watch == null? 0:textData.watch}}</span>
        </div>
        <div class="ft-rg">{{textData.like==null?0:textData.like}} 赞</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["textData"],
};
</script>

<style lang="less" scoped>
.contentBox {
  width: 700px;
  padding: 20px 0;
  border-bottom: 1px solid #ccc;
  cursor: pointer;
  .dangtu {
    h5 {
      font-weight: 400;
      font-size: 18px;
      color: #000;
      margin-bottom: 15px;
      cursor: pointer;
      &:hover {
        color: orange;
      }
    }
    .wenbenBox {
      h5 {
        font-weight: 400;
        font-size: 18px;
        color: #000;
        margin-bottom: 15px;
        cursor: pointer;
        &:hover {
          color: orange;
        }
      }
    }
    .imgBox {
      //   width: 220px;
      height: 150px;
      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    }
  }
  .duotu {
    h5 {
      font-weight: 400;
      font-size: 18px;
      color: #000;
      margin-bottom: 15px;

      &:hover {
        color: orange;
      }
    }
    .duotuimg {
      margin: 15px 0;
      img {
        width: 100%;
        height: 150px;
        object-fit: cover;
      }
    }
  }
  .content {
    height: 63px;
    font-size: 14px;
    line-height: 1.5;

    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .ftbox {
    display: flex;
    align-items: center;
    margin-top: 10px;
    justify-content: space-between;
    .ft-fl {
      font-size: 12px;
      color: #999;
      a {
        img {
          width: 16px;
          height: 16px;

          vertical-align: top;
        }
        span {
          color: orange;
        }
      }
    }
    .ft-rg {
      font-size: 16px;
      color: orange;
    }
  }
}
</style>